# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=ddclient
pkgver=3.9.1
pkgrel=1
pkgdesc="Ddclient is a Perl client used to update dynamic DNS entries for accounts on 'Dynamic DNS Network Services' free DNS service."
url="https://ddclient.net/"
arch="noarch"
license="GPL-2.0-only"
depends="perl perl-io-socket-ssl perl-io-socket-inet6 
perl-digest-sha1 net-tools perl-data-validate-ip"
pkgusers="$pkgname"
pkggroups="$pkgname"
options="!check" # no check provided
install="$pkgname.pre-install"
subpackages="$pkgname-openrc $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ddclient/ddclient/archive/v$pkgver.tar.gz
	$pkgname.initd
	pid-path.patch"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	return 0
}

package() {
	install -d "$pkgdir"/var/cache/ddclient/
	chown -R $pkgusers:$pkggroups "$pkgdir"/var/cache/ddclient

	install -Dm755 ddclient "$pkgdir"/usr/bin/$pkgname
	install -Dm755 $srcdir/ddclient.initd "$pkgdir"/etc/init.d/$pkgname

	install -Dm600 sample-etc_ddclient.conf "$pkgdir"/etc/ddclient/ddclient.conf.sample
	chown $pkgusers:$pkggroups "$pkgdir"/etc/ddclient
}

doc() {
	default_doc
	pkgdesc="$pkgname documentation"
	cd "$builddir"
	install -Dm644 sample-etc_cron.d_ddclient \
		"$subpkgdir"/usr/share/doc/ddclient/sample-etc_cron.d_ddclient
	install -Dm644 sample-etc_dhclient-exit-hooks \
		"$subpkgdir"/usr/share/doc/ddclient/sample-etc_dhclient-exit-hooks
	install -Dm644 sample-etc_ppp_ip-up.local "$subpkgdir"/usr/share/doc/ddclient/sample-etc_ppp_ip-up.local
}

sha512sums="a8a4d6cb94e4239a7b7b4fc7d9ebef703cbd6c45fc3394b644694a053b5b8aa8d109410b5b8b3676a5f30b18474d24c7feb16c65c30b28bd7d941d8a214b1346  ddclient-3.9.1.tar.gz
c5a4c4aef817692f73272a8aaf6edb10d3b16272577ef83c1f5db32b806933c410c7da0a7ce138655282a0671a8590879d6fe7c8f58f64c5cedfc1ed1cac710b  ddclient.initd
fc0137d0aead152be16081c6e64ba1e3e1786768020ac44a6baa36ee2f0f1b1d6b89116739b95091d7d0ebf02ab82b3e73491d975e46b7da31099f9481400253  pid-path.patch"
